<template>
  <div class="forget-pwd-container">
    <div class="main-container">
      <div class="main-item">
        <div class="label">原密码</div>
        <div class="value">
          <input type="text" placeholder="填写原密码" v-model="form.userpwd"/>
        </div>
      </div>
      <div class="main-item">
        <div class="label">新密码</div>
        <div class="value">
          <input type="text" placeholder="填写新密码" v-model="form.userpwd1"/>
        </div>
      </div>
      <div class="main-item">
        <div class="label">确认密码</div>
        <div class="value">
          <input type="text" placeholder="确认新密码" v-model="form.userpwd2"/>
        </div>
      </div>
    </div>
    <div class="tip-container">
      <div class="tip-1">密码必须是8-16位的数字、字符组合（不能是纯数字）</div>
      <div class="tip-2" @click="goTo">忘记原密码？</div>
    </div>
    <div class="ok-btn" @click="ok">完成</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        userpwd: null,
        userpwd1: null,
        userpwd2: null
      }
    };
  },
  methods: {
    async ok() {
      if (!this.form.userpwd) {
        this.$toast("请输入原密码");
        return;
      }
      if (!this.form.userpwd1) {
        this.$toast("请输入新密码");
        return;
      }
      if (this.form.userpwd1 !== this.form.userpwd2) {
        this.$toast('两次新密码输入不一致')
        return
      }
      const result = await this.$fetchPost('/home/login/pwd', this.form)
      if (!result.success) {
        this.$toast(result.msg)
        return
      }
      this.$toast('密码修改成功')
      this.$router.push('/my')
    },
    goTo () {
      this.$router.push('/forgetPwdPhone')
    }
  }
};
</script>

<style lang="scss">
.forget-pwd-container {
  .main-container {
    margin-top: 50px;
    box-shadow: 0 0 10px #888;
    background: #ffffff;
    .main-item {
      display: flex;
      border-bottom: 1px solid #ebebeb;
      padding: 20px 30px;
      box-sizing: border-box;
      .label {
        width: 150px;
        font-size: 28px;
        color: #525252;
        font-weight: 600;
      }
      .value {
        flex: 1;
        input {
          width: 80%;
          border: none;
          background: transparent;
        }
      }
    }
  }
  .tip-container {
    padding: 50px 30px;
    font-weight: 600;
    .tip-1 {
      color: #565656;
    }
    .tip-2 {
      margin-top: 5px;
      color: #4ea6fe;
    }
  }
  .ok-btn {
    margin-top: 50px;
    width: 80vw;
    margin-left: 10vw;
    text-align: center;
    line-height: 100px;
    background: linear-gradient(to right, #fc8f04, #f71c19);
    border-radius: 50px;
    font-size: 35px;
    font-weight: bold;
    color: #fff;
    letter-spacing: 10px;
  }
}
</style>